#pragma once
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <functional>
#include <unistd.h>

using namespace std;

typedef std::function<void()> func;

unordered_map<int, string> desc;
vector<func> callbacks;

void mystrcpy()
{
    cout <<"child process" << getpid() << "字符串拷贝" << endl;
}

void mystrstr()
{
    cout <<"child process" << getpid() <<  "字符串匹配" << endl;
}

void mystrcmp()
{
    cout <<"child process" << getpid() <<  "字符串比较" << endl;
}

void mystrlen()
{
    cout <<"child process" << getpid() <<  "字符串计数" << endl;
}

void load()
{
    desc.insert({callbacks.size(), "mystrcpy:字符串拷贝"}); 
    callbacks.push_back(mystrcpy);

    desc.insert({callbacks.size(), "mystrstr:字符串匹配"});    
    callbacks.push_back(mystrstr);

    desc.insert({callbacks.size(), "mystrcmp:字符串比较"});      
    callbacks.push_back(mystrcmp);

    desc.insert({callbacks.size(), "mystrlen:字符串计数"});
    callbacks.push_back(mystrlen);
}

void describe()
{
    for(const auto& e : desc)
    {
        cout << e.first << "\t" << e.second << endl;
    }
}